% This file generates Figure 9 in the paper. It runs the .m files below and
% combines the IRFs into a single figure in which each quadrant corresponds
% to a different specification of the baseline regression for ouput. 

clear; close all; clc;

global P H;
%% Options for S/LP:

P       =   2;      % Number of lags for endogenous variables.
H       =   9;      % Maximum number of leads.

%%  Including regression dummy. 

run FIG_9_Robustness_Output_recession.m;
figure;
subplot(2,3,1)
shadedplot(t,irf_slp_baseline_UB',irf_slp_baseline_LB',[0.75,0.75,0.75],'w');
hold on
U       =   plot(t,irf_slp,'x-b',t,irf_slp_zlb,'-r',...
            t,irf_slp_zlb_baseline_LB,'*--r',t,irf_slp_zlb_baseline_UB,'*--r','Linewidth',1.5);
hold on
h = legend(U, 'No ZLB','ZLB','Location','SouthEast');
set(h,'Interpreter','latex');
hold on
grid on
title('Including Recession Dummy','Interpreter','latex','fontSize',13);
xlabel('Horizon','Interpreter','latex','fontSize',12);
ylabel('Percent','Interpreter','latex','fontSize',12);
hold on
clearvars -except P H
%%  Growth rates specification.

run FIG_9_Robustness_Output_growth.m;

subplot(2,3,2);
shadedplot(t,irf_slp_baseline_UB',irf_slp_baseline_LB',[0.75,0.75,0.75],'w');
hold on
U       =   plot(t,irf_slp,'x-b',t,irf_slp_zlb,'-r',...
            t,irf_slp_zlb_baseline_LB,'*--r',t,irf_slp_zlb_baseline_UB,'*--r','Linewidth',1.5);
h = legend(U, 'No ZLB','ZLB','Location','SouthWest');
set(h,'Interpreter','latex');
hold on
axis([0 8 min(irf_slp_zlb_baseline_LB)-0.2 max(irf_slp_baseline_UB)+0.2 ]);
grid on
title('Growth Rates Specification','Interpreter','latex','fontSize',13);
xlabel('Horizon','Interpreter','latex','fontSize',12);
ylabel('Percent','Interpreter','latex','fontSize',12);

hold on
%%  Different definition of ZLB. 

run FIG_9_Robustness_Output_zlb.m;

subplot(2,3,3);
shadedplot(t,irf_slp_baseline_UB',irf_slp_baseline_LB',[0.75,0.75,0.75],'w');
hold on
U       =   plot(t,irf_slp,'x-b',t,irf_slp_zlb,'-r',...
            t,irf_slp_zlb_baseline_LB,'*--r',t,irf_slp_zlb_baseline_UB,'*--r','Linewidth',1.5);
h = legend(U, 'No ZLB','ZLB','Location','NorthEast');
set(h,'Interpreter','latex');
hold on
axis([0 8 min(irf_slp_zlb_baseline_LB)-0.2 max(irf_slp_baseline_UB)+0.2 ]);
grid on
title('Alternative ZLB Definition','Interpreter','latex','fontSize',12);
xlabel('Horizon','Interpreter','latex','fontSize',12);
ylabel('Percent','Interpreter','latex','fontSize',12);

hold on
%% Including linear trend. 

run FIG_9_Robustness_Output_time_trend.m;

subplot(2,3,4);
shadedplot(t,irf_slp_baseline_UB',irf_slp_baseline_LB',[0.75,0.75,0.75],'w');
hold on
U       =   plot(t,irf_slp,'x-b',t,irf_slp_zlb,'-r',...
            t,irf_slp_zlb_baseline_LB,'*--r',t,irf_slp_zlb_baseline_UB,'*--r','Linewidth',1.5);
h = legend(U, 'No ZLB','ZLB','Location','SouthWest');
set(h,'Interpreter','latex');
hold on
axis([0 8 min(irf_slp_zlb_baseline_LB)-0.2 max(irf_slp_baseline_UB)+0.2 ]);
grid on
title('Time Trend','Interpreter','latex','fontSize',13);
xlabel('Horizon','Interpreter','latex','fontSize',12);
ylabel('Percent','Interpreter','latex','fontSize',12);

hold on
%% Including quadratic trend. 

run FIG_9_Robustness_Output_time_trend_quadratic.m;

subplot(2,3,5)
shadedplot(t,irf_slp_baseline_UB',irf_slp_baseline_LB',[0.75,0.75,0.75],'w');
hold on
U       =   plot(t,irf_slp,'x-b',t,irf_slp_zlb,'-r',...
            t,irf_slp_zlb_baseline_LB,'*--r',t,irf_slp_zlb_baseline_UB,'*--r','Linewidth',1.5);
hold on
h = legend(U, 'No ZLB','ZLB','Location','SouthWest');
set(h,'Interpreter','latex');
hold on
grid on
title('Quadratic Time Trend','Interpreter','latex','fontSize',13);
xlabel('Horizon','Interpreter','latex','fontSize',12);
ylabel('Percent','Interpreter','latex','fontSize',12);
hold on


%% Different lag lengths. 

run FIG_9_Robustness_Output_lags.m;

subplot(2,3,6);
shadedplot(t,irf_slp_P_2_UB',irf_slp_P_2_LB',[0.75,0.75,0.75],'w');
hold on
U = plot(t,irf_slp_P_2,'x-k',t,irf_slp_P_3,'o-b',t,irf_slp_P_4,'*-r',t,...
    irf_slp_P_2_zlb,'-k',t,irf_slp_P_3_zlb,'-b',t,irf_slp_P_4_zlb,'-r','Linewidth',1.5);
h = legend(U,'$p=2$','$p=3$','$p=4$','ZLB','Location','NorthEast');
set(h,'Interpreter','latex');
hold on
axis([0 8 min(irf_slp_P_4_zlb)-0.2 max(irf_slp_P_2_UB)+0.2 ]);
grid on
title('Alternative Lags','Interpreter','latex','fontSize',12);
xlabel('Horizon','Interpreter','latex','fontSize',12);
ylabel('Percent','Interpreter','latex','fontSize',12);
hold on
